package sign_in.loginsystem.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import sign_in.loginsystem.annotation.Permissions;
import sign_in.loginsystem.model.util.RBody;
import sign_in.loginsystem.model.util.Result;
import sign_in.loginsystem.service.port.AccountService;
import sign_in.loginsystem.service.port.AdminService;
import sign_in.loginsystem.tool.Analyze;

@Slf4j
@RestController
public class AdminController {


    @Autowired
    Analyze analyze;


    @Autowired
    AccountService accountService;

    @Autowired
    AdminService adminService;


    @PostMapping("/administer")
    @Permissions(permission = "user:list")
    public Result administer( @RequestBody RBody body){
        return Result.success(adminService.allUser(body));
    }

    @PostMapping("/administer/editor")
    @Permissions(permission = "user:edit")
    public Result administerEdit(@RequestBody RBody body){
        return Result.success(adminService.editUser(body));
    }

    @PostMapping("/administer/delete")
    @Permissions(permission = "user:delete")
    public Result administerDel(@RequestBody RBody body){
        return Result.success(adminService.delUser(body));
    }
    @PostMapping("/administer/search")
    @Permissions(permission = "user:search")
    public Result administerSearch(@RequestBody RBody body){
        return Result.success(adminService.searchUser(body));
    }

    @PostMapping("/administer/create")
    @Permissions(permission = "user:create")
    public Result createUser(@RequestBody RBody body){
        return Result.success(adminService.createUser(body));
    }

}
